package com.shop.cereshop.commons.tencent.moderation.util;

import org.springframework.util.DigestUtils;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * @description:
 * @author zdd
 * @date 2025/10/26 15:24
 * @version 1.0
 */
public class HashUtils {

    public static String md5(String content) {
        return DigestUtils.md5DigestAsHex(content.getBytes(StandardCharsets.UTF_8));
    }

    public static String toBase64(String text) {
        if (text == null || text.isEmpty()) {
            throw new IllegalArgumentException("text不能为空");
        }
        return Base64.getEncoder().encodeToString(text.getBytes(StandardCharsets.UTF_8));
    }

    private HashUtils() {}

}
